package com;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;

public class GameTimer {

    public static int interval = 1;
    public static boolean isGoOn = true;//一直进行

    boolean init(GameMap gMap,GameRule gRule){
        int count = 0;
        GUI showTool = new GUI(gMap);

        try {
            while (true) {
                if (isGoOn == true){

                    System.out.print("第" + count + "次更新\n");
                    System.out.println("Interval = "+ this.interval);

                    gRule.update(gMap);

                    //gMap.output_map();
                    
                    showTool.showGrid();

                    Thread.sleep(interval * 500);
                    count++;
                    
                }
                else{
                  Thread.sleep(50);
                }
            }
        }catch(InterruptedException e){
            e.printStackTrace();
        }
        return true;
    }

    boolean start(GameMap gMap){
        GameRule gr = new GameRule();
        
        return  init(gMap,gr);
    }
    
}
